package com.njwb.day15.ts.impl;

import com.njwb.day15.ts.ITransaction;
import com.njwb.day15.util.DbUtil;

import java.sql.SQLException;

public class TransactioImpl  implements ITransaction {
    @Override
    public void begin() {
        try {
            DbUtil.getConnection().setAutoCommit(false);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void rollback() {
        try {
            DbUtil.getConnection().rollback();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void commit() {
        try {
            DbUtil.getConnection().commit();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
